<?php
// No directAcces
defined('_AppBackMiage') or die('Restricted access');

include_once (DS . "backoffice/include/header.php");
include_once( DS . "backoffice/include/toppanel_stage.php");

$nbrResultPerPage = 10;

if (isset($_GET['page']) && !empty($_GET['page']))
{
    $page = $_GET['page'];
    $nbr = (((int) $_GET['page'] - 1) * $nbrResultPerPage);
    $lstStage = Stage::getListAttente($nbrResultPerPage, $nbr);
}
else
{
    $page = 1;
    $lstStage = Stage::getListAttente($nbrResultPerPage, 0);
}

$count = Stage::attenteCount();
$pages = ceil($count / $nbrResultPerPage);
$pageSuivante = $page + 1;
$pagePrecendente = $page - 1;
?>
<div id="wrapper">
    <div id="content">
        <div id="rightnow">
            <h3 class="reallynow">
                <span>Liste des fiches de stages en attente de validation</span>
                <br/>
            </h3>
            <p class="youhave">
            <?php

            if (!empty($lstStage))
            {
            ?>
                <table width="100%">
                    <thead>
                        <tr>
                            <th>Titre</th>
                            <th>Etudiant</th>
                            <th>Entreprise</th>
                            <th width="60px">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php
                    foreach ($lstStage as $i=>$u)
                    {
                        $viewURL = URL."/index.php?m=admin_stages_fiches_attente_view&uid=".$u->IdStage;
                        //$editStage = URL . "/index.php?m=admin_userufr_edit&uid=" . $i;
                        ?>
                        <tr>
                            <td><?php echo stripcslashes($u->TitreStage); ?></td>
                            <td><?php $etudiant = new Etudiant($u->IdEtudiant); echo $etudiant->getNomUtilisateur()." ".$etudiant->getPrenomUtilisateur(); ?></td>
                            <td><?php   echo $u->NomEntreprise; ?></td>
                            <td>
                                <a href="<?php echo $viewURL; ?>">
                                    <img src="<?php echo STYLEBK; ?>img/icons/report.png" title="Mod&eacute;rer" width="16" height="16" />
                                </a>
                            </td>
                        </tr>
                    <?php
                    }
                    ?>
                    </tbody>
                </table>
                <div id="pager">
                Page
<?php if ($pagePrecendente > 0): ?>
                        <a href="<?php echo URL . "/index.php?m=admin_stages_fiches_attente_list&page=" . $pagePrecendente; ?>"><img src="<?php echo STYLEBK; ?>img/icons/arrow_left.gif" width="16" height="16" /></a>
                <?php endif; ?>
                <?php echo $page; ?>
<?php if ($pageSuivante <= $pages): ?>
                            <a href="<?php echo URL . "/index.php?m=admin_stages_fiches_attente_list&page=" . $pageSuivante; ?>"><img src="<?php echo STYLEBK; ?>img/icons/arrow_right.gif" width="16" height="16" /></a>
<?php endif; ?>
                            sur <?php echo $pages; ?> | Total <strong><?php echo $count; ?> </strong> stage<?php if ($count > 1)
                            {
                                echo 's';
                            } ?> en attente trouv&eacute;<?php if ($count > 1)
                            {
                                echo 's';
                            } ?>.
                            </div>
            <?php
            }
            else
            {
                echo 'Aucun';
            }
            ?>
            </p>
        </div>
    </div>
<?php
    include_once (DS . "backoffice/include/sidebar.php");
    include_once (DS . "backoffice/include/footer.php");
?>

